package com.innovation.chengzhangriji.ui;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.innovation.chengzhangriji.Baby;
import com.innovation.chengzhangriji.Config;
import com.innovation.chengzhangriji.R;
import com.innovation.chengzhangriji.database.DatabaseManager;
import com.innovation.chengzhangriji.ui.event.BaseEvent;
import com.innovation.chengzhangriji.ui.widget.CuteButton;
import com.innovation.chengzhangriji.ui.widget.CuteTextView;
import com.innovation.chengzhangriji.ui.widget.CuteToolbar;

import de.greenrobot.event.EventBus;

public class SettingsActivity extends BaseActivity implements CuteToolbar.OnClickCuteToolbarListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        // 初始化视图
        setupLayout();
    }

    // 初始化视图
    private void setupLayout() {
        CuteToolbar cuteToolbar = (CuteToolbar) findViewById(R.id.toolbar);
        cuteToolbar.setOnClickCuteToolbarListener(this);

        LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
        layout.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
    }

    @Override
    public void onClickLeft() {
        finish();
    }

    @Override
    public void onClickRight() {

    }

    // 账户安全页
    public void startAccountSafeActivity(View v) {
        startActivity(new Intent(this, AccountSafeActivity.class));
    }

    // 通用设置页
    public void startCommonSettingActivity(View v) {
        startActivity(new Intent(this, CommonSettingActivity.class));
    }

    // 关于我们页面
    public void startAboutUsActivity(View v) {
        startActivity(new Intent(this, AboutUsActivity.class));
    }

    // 退出登录
    public void logout(View v) {
        // 清除登录标记
        Config.cleanLogin(this);
        EventBus.getDefault().post(new BaseEvent(BaseEvent.TYPE_LOG_STATE_CHANGED));
    }
}
